﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataStructures
{
	/// <summary>
	/// Contains a list of ComplexTreeNode (or ComplexTreeNode-derived) objects, with the capability of linking parents and children in both directions.
	/// </summary>
	public class ComplexTreeList<T> : List<ComplexTree<T>> where T : ComplexTree<T>
	{
		public T Parent { get; set; }

		public ComplexTreeList(ComplexTree<T> parent)
		{
			Parent = (T)parent;
		}

		public T Add(T node)
		{
			base.Add(node);
			node.Parent = Parent;
			return node;
		}

		public override string ToString()
		{
			return "Count=" + Count.ToString();
		}
	}
}
